package com.WicsApp.android;

import java.io.IOException;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.text.method.ScrollingMovementMethod;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;


public class MinutesActivity extends BaseActivity 
{
    /** Called when the activity is first created. */
    @Override
    public void setContentView(View view) 
    {
     super.setContentView(view);
    }
    
    
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.minutes);
        
		
        Document doc;
		try {
			//doc = Jsoup.connect("http://cgi.sfu.ca/~wics/category/minutes/meeting-minutes").timeout(1000000).get();
			doc = Jsoup.connect("http://cgi.sfu.ca/~wics/?cat=3").timeout(1000000).get();
			
			
			String name = new String();
			//select the text of the minutes
			Elements elss = doc.getElementsByClass("entry");
			//select only the first minute and get each paragraph
			Elements els = elss.first().select("p");
			
			
			for(org.jsoup.nodes.Element el : els){
				//append a new line after each paragraph
				name += el.text() + "\n\n";
			}
			
			TextView t = (TextView) findViewById(R.id.TextView1);
			t.setMovementMethod(new ScrollingMovementMethod());
			t.setText(name);
			
			
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
        	
    }
	
}